import request from '@/utils/request';
import { PageResponse } from '@/interface/pages';

export interface AccountInfo {}

/**
 * 获取分页列表
 *
 * @returns Promise
 *
 * @todo 发起axios请求
 */
export const getAccountList = (params: API.account.PageListDto) => {
  return request<PageResponse<API.account.EntitySchema[]>>({
    url: '/admin/account',
    method: 'get',
    params
  });
};

// /**
//  * 获取帐号信息
//  *
//  * @param {}.account 帐号
//  * @param {}.password 密码
//  * @returns Promise
//  *
//  * @todo 发起axios请求
//  */
// export const adminAccountInfo = () => {
//   return request<AccountInfo>({
//     url: '/admin/account/info',
//     method: 'get'
//   });
// };

/**
 * 创建
 *
 * @returns Promise
 *
 * @todo 发起axios请求
 */
export const createAccount = (data: API.account.EntityDto): Promise<any> => {
  return request({
    url: `/admin/account`,
    method: 'post',
    data
  });
};

/**
 * 修改
 *
 * @returns Promise
 *
 * @todo 发起axios请求
 */
export const updateAccount = (
  id: number,
  data: API.account.EntityDto
): Promise<any> => {
  return request({
    url: `/admin/account/${id}`,
    method: 'put',
    data
  });
};

/**
 * 修改状态
 *
 * @param id
 * @param state
 * @returns Promise
 *
 * @todo 发起axios请求
 */
export const updateSwitch = (id: number, data: any) => {
  return request({
    url: `/admin/account/switch/${id}`,
    method: 'put',
    data
  });
};

/**
 * 重置密码
 *
 * @param id
 * @returns Promise
 *
 * @todo 发起axios请求
 */
export const resetAccountPwd = (id: number): Promise<any> => {
  return request({
    url: '/admin/account/resetpwd/' + id,
    method: 'put'
  });
};

/**
 * 修改密码
 *
 * @param data
 * @returns Promise
 *
 * @todo 发起axios请求
 */
export const repass = (data: API.account.RepassDto): Promise<any> => {
  return request({
    url: '/admin/account/repass',
    method: 'post',
    data
  });
};
